import 'package:example/page/page_detail/page.dart';
import 'package:example/page/page_home/page.dart';
import 'package:example/router/application.dart';
import 'package:example/router/routes.dart';
import 'package:fish_redux/fish_redux.dart';
import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart' hide Action, Page;
import 'package:flutter_screenutil/flutter_screenutil.dart';

/// 创建应用的根 Widget
class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final FluroRouter router = FluroRouter();

  @override
  void initState() {
    super.initState();
    Routes.configureRoutes(router);
    Application.router = router;
  }

  @override
  Widget build(BuildContext context) {
    return ScreenUtilInit(
      designSize: const Size(960, 675),
      builder: (BuildContext context) {
        ScreenUtil.setContext(context);
        return MaterialApp(
          title: 'Fluro',
          debugShowCheckedModeBanner: false,
          theme: ThemeData(
            primarySwatch: Colors.blue,
          ),
          onGenerateRoute: Application.router.generator,
          // home: routes.buildPage('todo_list', null),
          // onGenerateRoute: (RouteSettings settings) {
          //   return MaterialPageRoute<Object>(builder: (BuildContext context) {
          //     return routes.buildPage(settings.name!, settings.arguments);
          //   });
          // },
        );
      },
    );
  }
}
